//import com.fasterxml.jackson.annotation.JsonIgnore
package entity

import service.user.UserInfo
import java.util.*
import javax.persistence.*
import kotlin.collections.ArrayList
import kotlin.collections.HashSet


//@Entity
//@Table(name = "tb_user")
public class User {
    fun setUserInfo(userInfo: UserInfo) {
        userInfo.let {
            this.age = it.age ?: 0
            this.phoneNumber = it.phoneNumber
            this.gender = it.gender ?: ""
            this.userName = it.userName ?: ""
            this.userNumber = it.userNumber ?: ""
            this.avatar = it.avatar ?: ""
        }
    }

    //微信账号 的唯一标识
//    @JsonIgnore
    var wxOpenId = ""


    var id: Int = -1

    //手机号 账号
    var phoneNumber: String = ""

    //密码
    var password: String = ""

    //用户名 昵称
    var userName: String = ""

    //用户学号、老师工号
    var userNumber: String = ""

    //以下为用户选填信息
    var gender: String = ""

    var age = -1

    var avatar = ""

    //最后修改密码日期
//    @JsonIgnore
    var lastPasswordResetDate: Date = Date()

    //    @OneToMany(cascade = [CascadeType.ALL], fetch = FetchType.EAGER)
//    @JsonIgnore
//    @JoinColumn(name = "user_id")
    var myUdr: Set<Udr>? = HashSet()

    //....其他信息略


    //管理员要审核的活动
//    @JsonIgnore
//    @OneToMany(mappedBy = "examiner", fetch = FetchType.EAGER)
    var examinedActivities: Set<Activity> = HashSet<Activity>()

    //发起的活动
//    @JsonIgnore
//    @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
    var publishedActivities: Set<Activity> = HashSet<Activity>()

    override fun toString(): String {
        return "User(id=$id, userName='$userName', age='$age')"
    }

}